<!--#include file="lib/utf-8.asp"-->
<!--#include file="lib/conn.asp"-->
<!--#include file="lib/saferequest.asp"-->
<%
call CheckRights(3,1)

	sch=trim(replace(request.QueryString("sch"),"'","''"))
	ksrq=trim(replace(request.QueryString("ksrq"),"'","''"))
	if ksrq<>"" then ksrq=cdate(ksrq)
	jsrq=trim(replace(request.QueryString("jsrq"),"'","''"))
	if jsrq<>"" then jsrq=cdate(jsrq)
	kssj=trim(replace(request.QueryString("kssj"),"'","''"))
	if kssj<>"" then kssj=cdate(kssj)
	jssj=trim(replace(request.QueryString("jssj"),"'","''"))
	if jssj<>"" then jssj=cdate(jssj)
	tyr=SafeRequest("tyr",0)
	cyr=SafeRequest("cyr",0)
	If cyr="" Or cyr="承运人" Then cyr=0
	cd=SafeRequest("cd",0)
	If cd="" Or cd="车队" Then cd=0
	baozhang=Trim(saferequest("baozhang",0))
	sql="select * from yb LEFT JOIN cl ON yb.cyr = cl.clid where "
	if ksrq<>"" and jsrq<>"" then
		sql=sql&"(rq>=#"&ksrq&"# and rq<=#"&jsrq&"#) and "
	end if
	if kssj<>"" and jssj<>"" then
		sql=sql&"(baozhangsj>=#"&kssj&"# and baozhangsj<=#"&jssj&"#) and "
	end if
	if tyr<>"托运人" Or tyr="" then
		sql=sql&"tyr='"&tyr&"' and "
	end if
	if cyr<>0 then
		sql=sql&"cyr="&cyr&" and "
	end if
	if cd<>0 then
		sql=sql&"cl.sscd="&cd&" and "
	end if
	if baozhang<>"" then
		sql=sql&"baozhang="&baozhang&" and "
	end if
	xx=saferequest("xx",0)
    if sch<>"" then sql=sql&"(tx like '%"&sch&"%' or cbbz like '%"&sch&"%' or hx like '%"&sch&"%' or tyr like '%"&sch&"%' or cyr like '%"&sch&"%' or dd like '%"&sch&"%' or cmhc like '%"&sch&"%' or tdh like '%"&sch&"%' or xh like '%"&sch&"%' or fh like '%"&sch&"%') and "
    if xx<>"" then sql=sql&"xx = '"&xx&"' and "
    sql=sql&"post=2 "
	'response.write sql
	'response.end
	sum_sql="select sum(djf) as s_djf,sum(glf) as s_glf,sum(ltf) as s_ltf,sum(rlf) as s_rlf,sum(sjrlf) as s_sjrlf,sum(xlf) as s_xlf,sum(thf) as s_thf,sum(dcf) as s_dcf,sum(qtf) as s_qtf from ("&sql&")"
	set rs_sum = Server.CreateObject("ADODB.Recordset")
	rs_sum.open sum_sql,conn,1,1
	If Not rs_sum.eof Then
		s_djf=rs_sum("s_djf")
		s_glf=rs_sum("s_glf")
		s_ltf=rs_sum("s_ltf")
		s_rlf=rs_sum("s_rlf")
		s_sjrlf=rs_sum("s_sjrlf")
		s_xlf=rs_sum("s_xlf")
		s_thf=rs_sum("s_thf")
		s_dcf=rs_sum("s_dcf")
		s_qtf=rs_sum("s_qtf")
	End If
	rs_sum.close
	sql=sql&"order by rq,tyr,cyr,dd,id"




	'response.write sql
	set rs = Server.CreateObject("ADODB.Recordset")
	rs.open sql,conn,1,1
	If rs.eof Then
		response.write("没有检索到数据!")
		response.end
	End if
If saferequest("page",0)<>""  Then	page=clng(saferequest("page",0)) Else	page=1
pc=saferequest("pc",1)
If pc="" Then pc=25
rs.pagesize=pc
pagesize=rs.pagesize
pagecount=rs.pagecount
'page=clng(request.QueryString("page"))
if Not IsEmpty(page) then '如果page_num已经初始化...
	if Not IsNumeric(page) then '判断page_num值是否为数字
		page=1
	else
		page = clng(page) '接收page_num并化为数字型赋给page_num变量
	end if
	if page > pagecount then '如果接收的页数大于总页数
		rs.AbsolutePage = pagecount '设置当前显示页等于最后页
	elseif page <= 0 then '如果page小于等于0
		page=1
		rs.AbsolutePage = page '设置当前显示页等于第一页
	else
		rs.AbsolutePage = page '如果大于零,显示当前页等于接收的页数
	end if
	page = rs.AbsolutePage
end if
%>




<table class="contable">
	<thead>
  <tr>
    <th rowspan="2">序号</th>
    <th rowspan="2">日期</th>
    <th rowspan="2">托运人</th>
    <th rowspan="2">承运人</th>
    <th rowspan="2">地点</th>
    <th rowspan="2">时间</th>
    <th rowspan="2">提单号</th>
    <th rowspan="2">箱型</th>
    <th rowspan="2">箱号</th>
    <th rowspan="2">封号</th>
    <th colspan="12">成本费用</th>
  </tr>
  <tr>
	<th>提箱</th>
	<th>还箱</th>
	<th>吊机</th>
	<th>实际过路</th>
	<th>实际燃料</th>
	<th>修理</th>
	<th>提还</th>
	<th>堆存</th>
	<th>其他</th>
	<th>小计</th>
	<th>备注</th>
	<th>报账</th>
  </tr>
	</thead>
	<tbody>
<%
'while not rs.eof
for i=1 to rs.pagesize
	if rs.EOF then	Exit For
%>
  <tr>
	<td><a href="view_business.asp?id=<%=rs("id")%>" target="_blank"><%=rs.AbsolutePosition%></a></td>
    <td title="<%=rs("rq")%>"><%=ShortDate(rs("rq"))%></td>
    <td><%=rs("tyr")%></td>
    <td><%=rs("cph")%></td>
    <td><%=rs("dd")%></td>
    <td><%if Not isnull(rs("sj")) then response.write(FormatDateTime(rs("sj"),4))%></td>
    <td><%=rs("tdh")%></td>
    <td><%=rs("xx")%></td>
	<td><%=rs("xh")%></td>
	<td><%=rs("fh")%></td>
	<td><%=rs("tx")%></td>
	<td><%=rs("hx")%></td>
	<td><%=rs("djf")%></td>
	<td><%=rs("ltf")%></td>
	<td><%=rs("sjrlf")%></td>
	<td><%=rs("xlf")%></td>
	<td><%=rs("thf")%></td>
	<td><%=rs("dcf")%></td>
	<td><%=rs("qtf")%></td>
	<td><%xj=(rs("djf")+rs("ltf")+rs("xlf")+rs("dcf")+rs("qtf"))%><%=xj%></td>
	<td><%=rs("cbbz")%></td>
	<td><%if rs("baozhang") then response.write("√")%></td>
  </tr>
<%
	sum_djf=sum_djf+rs("djf")
	sum_ltf=sum_ltf+rs("ltf")
	sum_sjrlf=sum_sjrlf+rs("sjrlf")
	sum_xlf=sum_xlf+rs("xlf")
	sum_thf=sum_thf+rs("thf")
	sum_dcf=sum_dcf+rs("dcf")
	sum_qtf=sum_qtf+rs("qtf")
	sum_xj=sum_xj+xj

	rs.movenext()
'wend
Next
%>
</tbody>
<thead>
  <tr>
    <th>小计</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th><%=sum_djf%></th>
	<th><%=sum_ltf%></th>
	<th><%=sum_sjrlf%></th>
	<th><%=sum_xlf%></th>
	<th><%=sum_thf%></th>
	<th><%=sum_dcf%></th>
	<th><%=sum_qtf%></th>
	<th><%=sum_xj%></th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
  </tr>
  <%If page=rs.pagecount Then %>
  <tr>
    <th>总计</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
	<th><%=s_djf%></th>
	<th><%=s_ltf%></th>
	<th><%=s_sjrlf%></th>
	<th><%=s_xlf%></th>
	<th><%=s_thf%></th>
	<th><%=s_dcf%></th>
	<th><%=s_qtf%></th>
	<th><%s_xj=(s_djf+s_ltf+s_sjrlf+s_xlf+s_thf+s_dcf+s_qtf)%><%=s_xj%></th>
	<th>&nbsp;</th>
	<th>&nbsp;</th>
  </tr>
  <% End If %>
	</thead>
</table>
	<span id="pagebar">
		<%	If page>1 Then	%>
			[<a href="#" id="1">首页</a>]
			[<a href="#" id="<%=page-1%>">上一页</a>]
		<%
				End If
				If Not (page>=pagecount Or pagecount=0) Then
		%>
			[<a href="#" id="<%=page+1%>">下一页</a>]
			[<a href="#" id="<%=pagecount%>">尾页</a>]
		<%	End If %>
			第 <%=page%> 页 / 共 <%=pagecount%> 页
			转到<input id="page_val" type="text" size="2" maxlength="<%=Int(Log(pagecount))+1%>" value="<%=page%>" />页
			<input id="page_go" type="button" value="Go" />
	</span>
<%
rs.close
Set rs=Nothing
conn.close
Set conn=nothing
%>

